package com.whksoft.mymapplugin.utils;

import java.awt.*;
import java.awt.image.BufferedImage;

public class ImageUtils {
    public static BufferedImage resize(BufferedImage img, int newW, int newH) {
        int w = img.getWidth();
        int h = img.getHeight();
        BufferedImage dimg = new BufferedImage(newW, newH, img.getType());
        Graphics2D g = dimg.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g.drawImage(img, 0, 0, newW, newH, 0, 0, w, h, null);
        g.dispose();
        return dimg;
    }

    public static BufferedImage addIcon(BufferedImage bg, BufferedImage icon, int size){
        // TODO: 2021/2/18 在中间添加图标 
//        Graphics2D g = bg.createGraphics();
//        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
//                RenderingHints.VALUE_INTERPOLATION_BILINEAR);
//        int w = icon.getWidth();
//        int h = icon.getHeight();
//        int max = Math.max(w,h);
//        if(w==h){
//            if(size%2==1) size++;
//            int place = 64 - (size / 2);
//            g.drawImage(icon, place, place, size, size, null);
//            g.dispose();
//            return bg;
//        }
        return null;
    }
}
